//
//  LRStatusToolBar.swift
//  WeiboX
//
//  Created by admin on 05/12/2016.
//  Copyright © 2016 iOS_Objective-C. All rights reserved.
//

import UIKit

class LRStatusToolBarV: UIView {
	
	var statusVM: LRStatusVM? {
		didSet {
			repostBtn.setTitle(statusVM?.repostsCountContent, for: .normal)
			commentBtn.setTitle(statusVM?.commentsCountContent, for: .normal)
			attitudeBtn.setTitle(statusVM?.attitudesCountContent, for: .normal)
		}
	}
	
//	private lazy var seperateLine: UIImageView = {
//		let imageV = UIImageView.init(image: UIImage.init(named: "timeline_card_bottom_line"))
//		
//		imageV.highlightedImage = UIImage.init(named: "timeline_card_bottom_line_highlighted")
//		return imageV
//	}()
	
	private lazy var repostBtn: UIButton = {
		let btn: UIButton = UIButton.init(title: "retweet", imgName: "timeline_icon_retweet", backgroundImgName: "timeline_card_bottom_background", fontSize: 14, fontColor: UIColor.gray)
		return btn
	}()

	private lazy var commentBtn: UIButton = {
		let btn: UIButton = UIButton.init(title: "comment", imgName: "timeline_icon_comment", backgroundImgName: "timeline_card_bottom_background", fontSize: 14, fontColor: UIColor.gray)
		return btn
	}()
	
	private lazy var attitudeBtn: UIButton = {
		let btn: UIButton = UIButton.init(title: "like", imgName: "timeline_icon_unlike", backgroundImgName: "timeline_card_bottom_background", fontSize: 14, fontColor: UIColor.gray)
		return btn
	}()
	
//	private lazy var btnArray: [UIButton] = [UIButton]()
	
	override init(frame: CGRect) {
		super.init(frame: frame)
		
		setupUI()
	}
	
	required init?(coder aDecoder: NSCoder) {
		fatalError("init(coder:) has not been implemented")
	}

	private func setupUI() {
		
//		btnArray.append(repostBtn)
//		btnArray.append(commentBtn)
//		btnArray.append(unlikeBtn)
		
		addSubview(repostBtn)
		addSubview(commentBtn)
		addSubview(attitudeBtn)
//		addSubview(seperateLine)
		
		let leftLine = addSeperateLine()
		let rightLine = addSeperateLine()
		
		repostBtn.snp.makeConstraints { (make) in
			make.leading.top.bottom.equalToSuperview()
			make.width.equalTo(commentBtn)
		}
		
		commentBtn.snp.makeConstraints { (make) in
			make.top.bottom.equalTo(repostBtn)
			make.width.equalTo(attitudeBtn)
			make.leading.equalTo(repostBtn.snp.trailing)
		}
		
		attitudeBtn.snp.makeConstraints { (make) in
			make.top.bottom.equalTo(commentBtn)
			make.width.equalTo(repostBtn)
			make.leading.equalTo(commentBtn.snp.trailing)
			make.trailing.equalToSuperview()
		}
		
		leftLine.snp.makeConstraints { (make) in
			make.centerX.equalTo(repostBtn.snp.trailing)
			make.centerY.equalToSuperview()
		}
		
		rightLine.snp.makeConstraints { (make) in
			make.centerX.equalTo(commentBtn.snp.trailing)
			make.centerY.equalToSuperview()
		}
	}
	
	private func addSeperateLine() -> UIImageView {
		let imageV = UIImageView.init(image: UIImage.init(named: "timeline_card_bottom_line"))
		
//		imageV.highlightedImage = UIImage.init(named: "timeline_card_bottom_line_highlighted")
		addSubview(imageV)
		return imageV
	}
}
